;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 跟安装的包相关的配置
(require 'cl)

;;源
(setq package-archives '(("gnu" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
                         ("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
(package-initialize) ;; You might already have this line


;; 当emacs首次启动时，自动安装的库
(defvar tony1981/packages '(
			    company
			    swiper
			    counsel
;;			    go-mode
			    ) "default packages")
(setq package-selected-packages tony1981/packages)

(defun tony1981/packages-installed-p ()
  (loop for pkg in tony1981/packages
	when (not (package-installed-p pkg)) do (return nil)
	finally (return t)))

(unless (tony1981/packages-installed-p)
  (message "%s" "Refreshing package database...")
  (package-refresh-contents)
  (dolist (pkg tony1981/packages)
    (when (not (package-installed-p pkg))
      (package-install pkg))))


;; 一些库的基本配置
;;company
(add-hook 'after-init-hook 'global-company-mode)
(setq company-idle-delay 0.08)

;;swiper
(ivy-mode t)
(setq ivy-use-virtual-buffers t)


;;定义包名，这样就可以在别的地方require
(provide 'init-packages)
